#include <xact3.h>
#include <xact3d3.h>
#include "Audio.h"


//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
/*
AUDIO_STATE                 g_audioState;
bool DoesCommandLineContainAuditionSwitch();
void WINAPI XACTNotificationCallback( const XACT_NOTIFICATION* pNotification );


HRESULT PrepareAudio()
{

HRESULT hr;
WCHAR str[MAX_PATH];
HANDLE hFile;
DWORD dwFileSize;

HANDLE hMapFile;

ZeroMemory(&g_audioState, sizeof(AUDIO_STATE));

hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if( SUCCEEDED(hr))
{
	bool bAuditMode = DoesCommandLineContainAuditionSwitch();
	bool bDebug = false;

	DWORD dwCreationFlags = 0;
	if (bAuditMode)
		dwCreationFlags |= XACT_FLAG_API_AUDITION_MODE;
	hr = XACT3CreateEngine(dwCreationFlags, &g_audioState.pEngine);
}

if (FAILED(hr) || g_audioState.pEngine == NULL)
	return E_FAIL;

XACT_RUNTIME_PARAMETERS xrParams = {0};
xrParams.lookAheadTime = XACT_ENGINE_LOOKAHEAD_DEFAULT;
hr = g_audioState.pEngine->Initialize( &xrParams );
if ( FAILED( hr ) )
	return hr;

if (FAILED(hr = FindMediaFileCch(str, MAX_PATH, L"sounds.xwb")))
	return hr;

//Setting Up WaveBanks
if (FAILED(hr = FindMediaFileCch( str, MAX_PATH, L"sounds.xwb")))
	return hr;
hr = E_FAIL;
hFile = CreateFile( str, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if ( hFile != INVALID_HANDLE_VALUE )
{
	dwFileSize = GetFileSize(hFile, NULL);
	if( dwFileSize != -1)
	{
		hMapFile = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, dwFileSize, NULL);
		if(hMapFile)
		{
			g_audioState.pbWaveBank = MapViewOfFile(hMapFile, FILE_MAP_READ, 0 , 0 , 0);
			if(g_audioState.pbWaveBank)
			{
				hr = g_audioState.pEngine->CreateInMemoryWaveBank(g_audioState.pbWaveBank, dwFileSize, 0 , 0, &g_audioState.pWaveBank);
			}
			CloseHandle(hMapFile);
		}
	}
	CloseHandle(hFile);
}

//Setting Up SoundBanks
if (FAILED(hr = FindMediaFileCch(str, MAX_PATH, L"sounds.xwb")))
	return hr;
hr = E_FAIL;
hFile = CreateFile(str, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0 , NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
	dwFileSize = GetFileSize(hFile, NULL);
	if( dwFileSize != -1 )
	{
		g_audioState.pbSoundBank = new BYTE[dwFileSize];
		if(g_audioState.pbSoundBank)
		{
			if(0 != ReadFile(hFile, g_audioState.pbSoundBank, dwFileSize, &dwBytesRead, NULL))
			{
				hr = g_audioState.pEngine->CreateSoundBank(g_audioState.pbSoundBank, dwFileSize, 0 , 0, &g_audioState.pSoundBank);
			}
		}
	}
	CloseHandle(hFile);
}
*/